//封装自定义选中状态,数据处理方法
//反选某一条数据, 选中时添加数据,取消选中移除数据
//checkStatusData 当前选中数据, value元素值
export const selectItemFunc = (checkStatusData: any[], value: any) => {
	if (checkStatusData.indexOf(value) == -1) {
		//不存在
		checkStatusData.push(value);
	} else {
		//存在
		checkStatusData = checkStatusData.filter((item: any) => item != value);
	}
	return checkStatusData;
};
//全选操作
export const checkAllFunc = (totalData: any[], checkStatusData: any[], key: any) => {
	totalData.forEach((element: any) => {
		//obj[ident] 动态属性
		if (checkStatusData.indexOf(element[key]) == -1) {
			checkStatusData.push(element[key]);
		}
	});
	return checkStatusData;
};
//取消全选
export const cancelCheckAllFunc = (totalData: any[], checkStatusData: any[], key: any) => {
	totalData.forEach((element: any) => {
		if (checkStatusData.indexOf(element[key]) != -1) {
			checkStatusData = checkStatusData.filter((item: any) => item != element[key]);
		}
	});
	return checkStatusData;
};

// example:
//1 checkStatus.value = selectItemFunc(checkStatus.value, selectData.muid);
// if (v) {
// 	checkStatus.value.push(selectData.muid);
// } else {
// 	checkStatus.value = checkStatus.value.filter((item: any) => item != selectData.muid);
// }

//2 dataList.value.forEach((element: any) => {
// 	if (checkStatus.value.indexOf(element.muid) == -1) {
// 		checkStatus.value.push(element.muid);
// 	}
// });
// checkStatus.value = checkAllFunc(dataList.value, checkStatus.value, 'muid');

//3 dataList.value.forEach((element: any) => {
// 	if (checkStatus.value.indexOf(element.muid) != -1) {
// 		checkStatus.value = checkStatus.value.filter((item: any) => item != element.muid);
// 	}
// });
// checkStatus.value = cancelCheckAllFunc(dataList.value, checkStatus.value, 'muid');
// reload.value = !reload.value;
